/**
 * 主界面
 * 通知公告界面
*/ 
cc.Class({
    extends: cc.Component,

    properties: {
        noticeItemPre: cc.Prefab,   //通知公告预制
        contentPanel: cc.Node,      //显示通知公告的scrollview中content

    },

    // use this for initialization
    start: function () {
        this.refreshInfo();         
    },

    refreshInfo: function(){
        var recv = function(ret){
            if (ret.Code !== 0) {
                cc.error('DynamicUI',ret.Msg);
                //ComponentsUtils.showTips(ret.Msg);
            }else{
                ComponentsUtils.unblock();
                //对返回数据做安全处理
                if(!Utils.isEffective(ret.Data)){
                    return;        
                }
                this.initNoticeList(ret);
            }
            
        }.bind(this);
        
        var data = {
            Token:User.getLoginToken(),
            LotteryCode: 0,  //this.chatRoomPlayId,
        };
        CL.HTTP.sendRequest(DEFINE.HTTP_MESSAGE.POSTNEWS, data, recv.bind(this),"POST");     
        ComponentsUtils.block();
        
    },

    //显示通知公告的数据内容
    initNoticeList: function(data){
        for(var i=0;i<data.Data.length;++i){
            var noticeItem =cc.instantiate(this.noticeItemPre);
            noticeItem.getComponent('notice_item').init(data.Data[i]);
            this.contentPanel.addChild(noticeItem);                                                                                                                                                                                                                                                                                            
        }
        
    },

    // called every frame, uncomment this function to activate update callback
    // update: function (dt) {
        
    // },
});
